package cn.bellychang.leetcode.question315;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ChangLiang
 * @date 2021/2/19
 */
public class Solution {

    public List<Integer> countSmaller(int[] nums) {

        List<Integer> list = new ArrayList<>();

        for (int i = 0; i < nums.length; i++) {
            list.add(getRightSmaller(nums, i));
        }
        return list;
    }

    private int getRightSmaller(int[] nums, int index) {
        int result = 0;
        for (int i = index+1; i < nums.length; i++) {
            if (nums[i] < nums[index]) {
                result++;
            }
        }
        return result;
    }
}
